<?php
namespace app\index\controller;
use think\Controller;
use app\common\model\Mold as MoldModel;

class Mold extends Controller
{
    public function index()
    {
    	$model = new MoldModel();

    	$where["status"] = 1;

    	$data = $model->where($where)->where("pid",0)->order("sort asc")->select();
        
    	foreach ($data as $key => $value) {

    		$data2 = $model->where($where)->where("pid",$value["id"])->order("sort asc")->select();

    		$data[$key]["child"] = $data2;
    	}

        // 推荐
        $where["recommend"] = 1;

        $recommend = $model->where($where)->order("sort asc")->select();

        return $this->fetch("",["active"=>2,"menu"=>$data,"recommend"=>$recommend]);
    }
}
